import 'package:flutter/material.dart';
import 'package:flutter_test_demo/pages/home/components/ProjectInfo.dart';
import 'package:flutter_test_demo/static/colors/MyColors.dart';

class HotOrderedPage extends StatelessWidget {
  const HotOrderedPage({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
      // 已订购
    List onOrder = [
      {"image":"images/book/1.jpg","name":"孩子认真学习", "money": '12.3',"des":"这是一个 '孩子认真学习' 的故事"},
      {"image":"images/book/2.jpg","name":"情商决定一生", "money": '12.3',"des":"这是一个 '情商决定一生' 的故事"},
      {"image":"images/book/3.jpg","name":"道德经", "money": '12.3',"des":"这是一个 '道德经' 的故事"},
      {"image":"images/book/4.jpg","name":"深爱这个城", "money": '12.3',"des":"这是一个 '深爱这个城' 的故事"},
      {"image":"images/book/5.jpg","name":"只因目中无人", "money": '12.3',"des":"这是一个 '只因目中无人' 的故事"},
      {"image":"images/book/6.jpg","name":"人文讲坛目录", "money": '12.3',"des":"这是一个 '人文讲坛目录' 的故事"},
      {"image":"images/book/7.jpg","name":"犯罪心理", "money": '12.3',"des":"这是一个 '犯罪心理' 的故事"},
      {"image":"images/book/8.jpg","name":"养猪学", "money": '12.3',"des":"这是一个 '养猪学' 的故事"},
    ];

    return Column(
      children: <Widget>[
        Padding(
            padding: EdgeInsets.symmetric(
              vertical: 20.0,
              horizontal: 12.0
            ),
            child: Row(
              children: <Widget>[
                DecoratedBox(
                  decoration: BoxDecoration(
                    color: MyColor.titleColor,
                  ),
                  child: ConstrainedBox(
                    constraints: BoxConstraints.tightFor(
                      width: 4.0,
                      height: 20.0
                    ),
                  ),
                ),
                Padding(
                  padding: EdgeInsets.only(left: 15.0),
                  child: Text(
                    "热门推荐",
                    style: TextStyle(
                      color: MyColor.titleColor,
                      fontSize: 18.0
                    ),
                  ),
                ),
              ],
            ),
          ),

          // 热门推荐 List
          Column(
            verticalDirection:VerticalDirection.up,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: onOrder.map((item) => 
              Padding(
                padding: EdgeInsets.symmetric(
                  vertical: 10.0,
                  horizontal: 15.0
                ),
                child: GestureDetector(
                  onTap: (){
                    print(item);
                    Navigator.push(context,   MaterialPageRoute(builder: (context) => ProjectInfo(reInfo: item),));

                  },
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.start,
                    children: <Widget>[
                      ConstrainedBox(
                        constraints: BoxConstraints.tightFor(
                          width: 120.0,
                          height: 120.0
                        ),
                        child: Image.asset(
                          item['image'],
                          width: 100.0,
                          fit: BoxFit.fitWidth,
                        ),
                      ),
                      SizedBox(width: 10.0,),
                      // 信息列表
                      ConstrainedBox(
                        constraints: BoxConstraints.tightFor(
                          height: 120.0
                        ),
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          mainAxisAlignment: MainAxisAlignment.spaceAround,
                          children: <Widget>[
                            Text(
                              item['name'],
                              style: TextStyle(
                                fontSize: 18.0,
                                fontWeight: FontWeight.w700
                              ),
                            ),
                            Text("金额： \$"+ (item['money']?? "0").toString()),
                            Text("描述： "+ (item['des']?? "无描述").toString()),
                          ],
                        )
                      )
                    ],
                  ),
                )
              ),
            ).toList(),
            
          )
      ],
    );
  }
}